package cn.guo.dao.impl;


import org.hibernate.SessionFactory;

import cn.guo.dao.IUserDao;
import cn.guo.entity.User;


public class UserDao implements IUserDao {

	//
	private SessionFactory sessionFactory;
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public User findByUser(User user) {
		return (User) sessionFactory.getCurrentSession()//
				.createQuery("from User where uname=? and upassword=?")//
				.setString(0, user.getUname())//
				.setString(1, user.getUpassword())//
				.uniqueResult();
	}

	public void save(User user) {
		sessionFactory.getCurrentSession().save(user);
	}

	
}